package com.yanqu.road.dao.impl.zhaoshang;

import com.yanqu.road.dao.db.DbNameStrategy;
import com.yanqu.road.dao.impl.TempDao;
import com.yanqu.road.entity.config.zhaoshang.ZsProjectInfo;

import java.sql.CallableStatement;
import java.sql.ResultSet;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public class ZsConfigDaoImpl extends TempDao {


    public Map<Integer, ZsProjectInfo> getZsProjectInfo() {
        ResultSet rs = null;
        CallableStatement call = null;
        String sql = "select * from t_p_zs_project_info ";
        Map<Integer, ZsProjectInfo> dataMap = new ConcurrentHashMap<>();
        try {
            getDb().setConnName(DbNameStrategy.getConfigDb());
            call = getDb().getConnection().prepareCall(sql);
            rs = call.executeQuery();
            while (rs.next()) {
                ZsProjectInfo data = new ZsProjectInfo();
                data.setId(rs.getInt("id"));
                data.setType(rs.getInt("type"));
                data.setConsume(rs.getString("consume"));
                data.setTime(rs.getInt("time"));
                data.setRewards(rs.getString("rewards"));
                data.setSeatNum(rs.getInt("seatNum"));
                data.setWorship(rs.getString("worship"));
                dataMap.put(data.getId() , data);
            }
        }catch (Exception e) {
            throw new RuntimeException(e);
        } finally {
            getDb().closeConnection(call, rs);
        }
        return dataMap;
    }

}
